import 'package:bruno/bruno.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:miaowu/app/theme/font.dart';

class PondSortPopWidget {
  static show(BuildContext context, {required GlobalKey<State<StatefulWidget>> sortKey, int sortCheck = 0}) {
    BrnPopupWindow.showPopWindow(
      context,
      "提示内容",
      sortKey,
      spaceMargin: -5,
      backgroundColor: Colors.white,
      borderColor: Colors.white,
      borderWidth: 0,
      offset: 0,
      widget: SizedBox(
        height: 134,
        width: 107,
        child: Column(
          children: [
            GestureDetector(
              onTap: () {},
              child: _buildSortWarpper(name: '最新优先', isCheck: sortCheck == 0),
            ),
            _buildLineWarpper(),
            GestureDetector(
              onTap: () {},
              child: _buildSortWarpper(name: '未读优先', isCheck: sortCheck == 1),
            ),
            _buildLineWarpper(),
            GestureDetector(
              onTap: () {},
              child: _buildSortWarpper(name: '在线优先', isCheck: sortCheck == 2),
            ),
          ],
        ),
      ),
      paddingInsets: const EdgeInsets.all(5),
    );
  }

  static Container _buildLineWarpper() {
    return Container(
        height: 1,
        margin: const EdgeInsets.symmetric(horizontal: 10),
        alignment: Alignment.center,
        color: Colors.black.withOpacity(0.2));
  }

  static Container _buildSortWarpper({required String name, bool isCheck = false}) {
    return Container(
      height: 44,
      alignment: Alignment.center,
      child: Row(
        mainAxisAlignment: MainAxisAlignment.center,
        children: [
          Text(name,
              style: TextStyle(color: const Color(0xFF333333), fontSize: 14.sp, fontWeight: AppFontWeight.medium)),
          Padding(
            padding: const EdgeInsets.only(left: 8.0),
            child: isCheck ? Image.asset('assets/app/images/pond/pond_pop_check.png', width: 11) : const SizedBox(),
          )
        ],
      ),
    );
  }
}
